#include "../global.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    vtkCreate(reader, vtkDICOMImageReader);
    reader->SetDataByteOrderToLittleEndian();
    reader->SetDirectoryName(path.toStdString().c_str());
    reader->Update();

    vtkCreate(cubes, vtkMarchingCubes);
    cubes->SetInputConnection(reader->GetOutputPort());
    cubes->ComputeNormalsOn();
    cubes->SetValue(0, 250);

    vtkCreate(boneStripper, vtkStripper);
    boneStripper->SetInputConnection(cubes->GetOutputPort());

    vtkCreate(bi, vtkPolyDataNormals);
    bi->SetInputConnection(boneStripper->GetOutputPort());
    bi->SetComputeCellNormals(1);
    bi->SetComputePointNormals(1);
    bi->Update();

    vtkCreate(boneMapper, vtkPolyDataMapper);
    boneMapper->SetInputConnection(bi->GetOutputPort());

    vtkCreate(bone, vtkActor);
    bone->SetMapper(boneMapper);
    bone->GetProperty()->SetDiffuseColor(.1,.94,.52);
    bone->GetProperty()->SetSpecular(.3);
    bone->GetProperty()->SetSpecularPower(20);

    vtkCreate(renderer, vtkRenderer);
    vtkCreate(camera, vtkCamera);
    camera->SetViewUp(0,0,-1);
    camera->SetPosition(0,1,0);
    camera->SetFocalPoint(0,0,0);
    camera->Dolly(1.5);

    renderer->AddActor(bone);
    renderer->SetActiveCamera(camera);
    renderer->ResetCamera();
    renderer->SetBackground(0,0,0);
    renderer->ResetCameraClippingRange();

    vtkCreate(style, vtkInteractorStyleTrackballCamera);
    vtkWidgetCreate(widget, QVTKWidget);
    QVTKWidget* vtkWidget = widget.data();
    vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(style);
    vtkWidget->GetRenderWindow()->AddRenderer(renderer);
    vtkWidget->resize(WINDOW_WIDTH, WINDOW_HEIGHT);
    vtkWidget->show();

    return a.exec();
}
